#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

#define DEBUG 0
#define NOISY_TEST 1

int checkgreathall(int player, struct gameState *post, int handPos) {

       struct gameState pre;
        memcpy (&pre, post, sizeof(struct gameState));
	    int r, i;
    r = cardEffect(great_hall,0,0,0,post, handPos,0 );
      //+1 Card
      drawCard(player, &pre);
			
      //+1 Actions
      pre.numActions++;
			
      //discard card from hand
      discardCard(handPos, player, &pre, 0);
	  assert(r==0);
      return 0;
}
int main () {

  int i, n, r, p, handPos;

  struct gameState G;

  printf ("Testing greathall.\n");

  printf ("RANDOM TESTS.\n");

  SelectStream(2);
  PutSeed(3);

	for (n = 0; n < 2000; n++) {
        for (i = 0; i < sizeof(struct gameState); i++) {
        ((char*)&G)[i] = floor(Random() * 256);
                }
                p = floor(Random() * MAX_PLAYERS); 
                G.deckCount[p] = floor(Random() * MAX_DECK);
                G.discardCount[p] = floor(Random() * MAX_DECK);
                G.handCount[p] = floor(Random() * MAX_HAND);
                G.playedCardCount = floor(Random() * MAX_DECK);
                G.whoseTurn = p;
                                                
                handPos = (int)(Random() * G.handCount[p]);
                checkgreathall(p, &G, handPos);                 
        }
	printf ("tests are fine and dandy\n");
	exit(0);
  return 0;
}
